package com.example.app.data.enum

import com.example.app.R

enum class TipState(
    var label: String,
    var value: Any,
    var key: String
) {

    //弹窗类型
    TIP_SUCCESS(
        "成功",
        0,
        "TIP_SUCCESS"
    ),
    TIP_ERROR(
        "错误",
        1,
        "TIP_ERROR"
    ),
    TIP_INFO(
        "提示",
        2,
        "TIP_INFO"
    ),
    TIP_LOADING(
        "加载中...",
        3,
        "TIP_LOADING"
    )
    ;

    companion object {
        fun getVarByLabel(label: String): TipState? {
            values().forEach {
                if (label == it.label) return it
            }
            return null
        }

        fun getVarByValue(value: Any): TipState? {
            values().forEach {
                if (value == it.value) return it
            }
            return null
        }

        fun getVarByKey(key: String): TipState? {
            values().forEach {
                if (it.key == key) return it
            }
            return null
        }
    }
}